﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using HslCommunication.Core;
using HslCommunication.Reflection;
using Newtonsoft.Json.Linq;

namespace HslCommunication.Enthernet
{
	/// <summary>
	/// 与服务器文件引擎交互的客户端类，支持操作Advanced引擎和Ultimate引擎，用来上传，下载，删除服务器中的文件操作。<br />
	/// The client class that interacts with the server file engine, supports the operation of the Advanced engine and the Ultimate engine,
	/// and is used to upload, download, and delete file operations on the server.
	/// </summary>
	/// <remarks>
	/// 这里需要需要的是，本客户端支持Advanced引擎和Ultimate引擎文件服务器，服务的类型需要您根据自己的需求来选择。
	/// <note type="important">需要注意的是，三个分类信息，factory, group, id 的字符串是不区分大小写的。</note>
	/// </remarks>
	/// <example>
	/// 此处只演示创建实例，具体的上传，下载，删除的例子请参照对应的方法
	/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="Intergration File Client" title="IntegrationFileClient示例" />
	/// </example>
	// Token: 0x020000F6 RID: 246
	public class IntegrationFileClient : FileClientBase
	{
		/// <summary>
		/// 实例化一个默认的对象，需要提前指定服务器的远程地址<br />
		/// Instantiate a default object, you need to specify the remote address of the server in advance
		/// </summary>
		// Token: 0x060014BE RID: 5310 RVA: 0x0006B806 File Offset: 0x00069A06
		public IntegrationFileClient()
		{
		}

		/// <summary>
		/// 通过指定的Ip地址及端口号实例化一个对象<br />
		/// Instantiate an object with the specified IP address and port number
		/// </summary>
		/// <param name="ipAddress">服务器的ip地址</param>
		/// <param name="port">端口号信息</param>
		// Token: 0x060014BF RID: 5311 RVA: 0x0006B810 File Offset: 0x00069A10
		public IntegrationFileClient(string ipAddress, int port)
		{
			base.ServerIpEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), port);
		}

		/// <inheritdoc cref="F:HslCommunication.Core.Net.NetworkBase.fileCacheSize" />
		// Token: 0x170004F2 RID: 1266
		// (get) Token: 0x060014C0 RID: 5312 RVA: 0x0006B82D File Offset: 0x00069A2D
		// (set) Token: 0x060014C1 RID: 5313 RVA: 0x0006B835 File Offset: 0x00069A35
		public int FileCacheSize
		{
			get
			{
				return this.fileCacheSize;
			}
			set
			{
				this.fileCacheSize = value;
			}
		}

		/// <summary>
		/// 删除服务器的文件操作，需要指定文件名称，文件的三级分类信息<br />
		/// Delete the file operation of the server, you need to specify the file name and the three-level classification information of the file
		/// </summary>
		/// <param name="fileName">文件名称，带后缀</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014C2 RID: 5314 RVA: 0x0006B840 File Offset: 0x00069A40
		[HslMqttApi(ApiTopic = "DeleteFileFactoryGroupId", Description = "Delete the file operation of the server, you need to specify the file name and the three-level classification information of the file")]
		public OperateResult DeleteFile(string fileName, string factory, string group, string id)
		{
			return base.DeleteFileBase(fileName, factory, group, id);
		}

		/// <summary>
		/// 删除服务器的文件操作，此处文件的分类为空<br />
		/// Delete the file operation of the server, the classification of the file is empty here
		/// </summary>
		/// <param name="fileName">文件名称，带后缀</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014C3 RID: 5315 RVA: 0x0006B85D File Offset: 0x00069A5D
		[HslMqttApi(Description = "Delete the file operation of the server, the classification of the file is empty here")]
		public OperateResult DeleteFile(string fileName)
		{
			return base.DeleteFileBase(fileName, "", "", "");
		}

		/// <summary>
		/// 删除服务器的文件数组操作，需要指定文件名称，文件的三级分类信息<br />
		/// Delete the file operation of the server, you need to specify the file names and the three-level classification information of the file
		/// </summary>
		/// <param name="fileNames">文件名称数组，带后缀</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014C4 RID: 5316 RVA: 0x0006B878 File Offset: 0x00069A78
		[HslMqttApi(ApiTopic = "DeleteFilesFactoryGroupId", Description = "Delete the file operation of the server, you need to specify the file names and the three-level classification information of the file")]
		public OperateResult DeleteFile(string[] fileNames, string factory, string group, string id)
		{
			return base.DeleteFileBase(fileNames, factory, group, id);
		}

		/// <summary>
		/// 删除服务器的文件夹的所有文件操作，文件的三级分类信息<br />
		/// Delete all file operations of the server folder, the three-level classification information of the file
		/// </summary>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014C5 RID: 5317 RVA: 0x0006B898 File Offset: 0x00069A98
		[HslMqttApi(Description = "Delete all file operations of the server folder, the three-level classification information of the file")]
		public OperateResult DeleteFolderFiles(string factory, string group, string id)
		{
			return base.DeleteFolder(factory, group, id);
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DeleteFile(System.String,System.String,System.String,System.String)" />
		// Token: 0x060014C6 RID: 5318 RVA: 0x0006B8B4 File Offset: 0x00069AB4
		[DebuggerStepThrough]
		public Task<OperateResult> DeleteFileAsync(string fileName, string factory, string group, string id)
		{
			IntegrationFileClient.<DeleteFileAsync>d__9 <DeleteFileAsync>d__ = new IntegrationFileClient.<DeleteFileAsync>d__9();
			<DeleteFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DeleteFileAsync>d__.<>4__this = this;
			<DeleteFileAsync>d__.fileName = fileName;
			<DeleteFileAsync>d__.factory = factory;
			<DeleteFileAsync>d__.group = group;
			<DeleteFileAsync>d__.id = id;
			<DeleteFileAsync>d__.<>1__state = -1;
			<DeleteFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DeleteFileAsync>d__9>(ref <DeleteFileAsync>d__);
			return <DeleteFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DeleteFile(System.String)" />
		// Token: 0x060014C7 RID: 5319 RVA: 0x0006B918 File Offset: 0x00069B18
		[DebuggerStepThrough]
		public Task<OperateResult> DeleteFileAsync(string fileName)
		{
			IntegrationFileClient.<DeleteFileAsync>d__10 <DeleteFileAsync>d__ = new IntegrationFileClient.<DeleteFileAsync>d__10();
			<DeleteFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DeleteFileAsync>d__.<>4__this = this;
			<DeleteFileAsync>d__.fileName = fileName;
			<DeleteFileAsync>d__.<>1__state = -1;
			<DeleteFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DeleteFileAsync>d__10>(ref <DeleteFileAsync>d__);
			return <DeleteFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DeleteFile(System.String[],System.String,System.String,System.String)" />
		// Token: 0x060014C8 RID: 5320 RVA: 0x0006B964 File Offset: 0x00069B64
		[DebuggerStepThrough]
		public Task<OperateResult> DeleteFileAsync(string[] fileNames, string factory, string group, string id)
		{
			IntegrationFileClient.<DeleteFileAsync>d__11 <DeleteFileAsync>d__ = new IntegrationFileClient.<DeleteFileAsync>d__11();
			<DeleteFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DeleteFileAsync>d__.<>4__this = this;
			<DeleteFileAsync>d__.fileNames = fileNames;
			<DeleteFileAsync>d__.factory = factory;
			<DeleteFileAsync>d__.group = group;
			<DeleteFileAsync>d__.id = id;
			<DeleteFileAsync>d__.<>1__state = -1;
			<DeleteFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DeleteFileAsync>d__11>(ref <DeleteFileAsync>d__);
			return <DeleteFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DeleteFolderFiles(System.String,System.String,System.String)" />
		// Token: 0x060014C9 RID: 5321 RVA: 0x0006B9C8 File Offset: 0x00069BC8
		[DebuggerStepThrough]
		public Task<OperateResult> DeleteFolderFilesAsync(string factory, string group, string id)
		{
			IntegrationFileClient.<DeleteFolderFilesAsync>d__12 <DeleteFolderFilesAsync>d__ = new IntegrationFileClient.<DeleteFolderFilesAsync>d__12();
			<DeleteFolderFilesAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DeleteFolderFilesAsync>d__.<>4__this = this;
			<DeleteFolderFilesAsync>d__.factory = factory;
			<DeleteFolderFilesAsync>d__.group = group;
			<DeleteFolderFilesAsync>d__.id = id;
			<DeleteFolderFilesAsync>d__.<>1__state = -1;
			<DeleteFolderFilesAsync>d__.<>t__builder.Start<IntegrationFileClient.<DeleteFolderFilesAsync>d__12>(ref <DeleteFolderFilesAsync>d__);
			return <DeleteFolderFilesAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 下载服务器的文件到本地的文件操作，需要指定下载的文件的名字，三级分类信息，本次保存的文件名，支持进度报告。<br />
		/// To download a file from the server to a local file, you need to specify the name of the downloaded file, 
		/// the three-level classification information, the name of the file saved this time, and support for progress reports.
		/// </summary>
		/// <param name="fileName">文件名称，带后缀</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="processReport">下载的进度报告，第一个数据是已完成总接字节数，第二个数据是总字节数。</param>
		/// <param name="fileSaveName">准备本地保存的名称</param>
		/// <returns>是否成功的结果对象</returns>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常，或是服务器不存在文件。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="Download File" title="DownloadFile示例" />
		/// </example>
		// Token: 0x060014CA RID: 5322 RVA: 0x0006BA24 File Offset: 0x00069C24
		[HslMqttApi(Description = "To download a file from the server to a local file, you need to specify the name of the downloaded file and three-level classification information")]
		public OperateResult DownloadFile(string fileName, string factory, string group, string id, Action<long, long> processReport, string fileSaveName)
		{
			return base.DownloadFileBase(factory, group, id, fileName, processReport, fileSaveName);
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64},System.String)" />
		// Token: 0x060014CB RID: 5323 RVA: 0x0006BA48 File Offset: 0x00069C48
		public OperateResult DownloadFile(string fileName, string factory, string group, string id, Action<long, long> processReport, Stream stream)
		{
			return base.DownloadFileBase(factory, group, id, fileName, processReport, stream);
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64},System.String)" />
		// Token: 0x060014CC RID: 5324 RVA: 0x0006BA6C File Offset: 0x00069C6C
		public OperateResult<Bitmap> DownloadFile(string fileName, string factory, string group, string id, Action<long, long> processReport)
		{
			MemoryStream memoryStream = new MemoryStream();
			OperateResult operateResult = base.DownloadFileBase(factory, group, id, fileName, processReport, memoryStream);
			bool flag = !operateResult.IsSuccess;
			OperateResult<Bitmap> result;
			if (flag)
			{
				memoryStream.Dispose();
				result = OperateResult.CreateFailedResult<Bitmap>(operateResult);
			}
			else
			{
				Bitmap value = new Bitmap(memoryStream);
				memoryStream.Dispose();
				result = OperateResult.CreateSuccessResult<Bitmap>(value);
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64},System.String)" />
		// Token: 0x060014CD RID: 5325 RVA: 0x0006BACC File Offset: 0x00069CCC
		[DebuggerStepThrough]
		public Task<OperateResult> DownloadFileAsync(string fileName, string factory, string group, string id, Action<long, long> processReport, string fileSaveName)
		{
			IntegrationFileClient.<DownloadFileAsync>d__16 <DownloadFileAsync>d__ = new IntegrationFileClient.<DownloadFileAsync>d__16();
			<DownloadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DownloadFileAsync>d__.<>4__this = this;
			<DownloadFileAsync>d__.fileName = fileName;
			<DownloadFileAsync>d__.factory = factory;
			<DownloadFileAsync>d__.group = group;
			<DownloadFileAsync>d__.id = id;
			<DownloadFileAsync>d__.processReport = processReport;
			<DownloadFileAsync>d__.fileSaveName = fileSaveName;
			<DownloadFileAsync>d__.<>1__state = -1;
			<DownloadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadFileAsync>d__16>(ref <DownloadFileAsync>d__);
			return <DownloadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64},System.IO.Stream)" />
		// Token: 0x060014CE RID: 5326 RVA: 0x0006BB40 File Offset: 0x00069D40
		[DebuggerStepThrough]
		public Task<OperateResult> DownloadFileAsync(string fileName, string factory, string group, string id, Action<long, long> processReport, Stream stream)
		{
			IntegrationFileClient.<DownloadFileAsync>d__17 <DownloadFileAsync>d__ = new IntegrationFileClient.<DownloadFileAsync>d__17();
			<DownloadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<DownloadFileAsync>d__.<>4__this = this;
			<DownloadFileAsync>d__.fileName = fileName;
			<DownloadFileAsync>d__.factory = factory;
			<DownloadFileAsync>d__.group = group;
			<DownloadFileAsync>d__.id = id;
			<DownloadFileAsync>d__.processReport = processReport;
			<DownloadFileAsync>d__.stream = stream;
			<DownloadFileAsync>d__.<>1__state = -1;
			<DownloadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadFileAsync>d__17>(ref <DownloadFileAsync>d__);
			return <DownloadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014CF RID: 5327 RVA: 0x0006BBB4 File Offset: 0x00069DB4
		[DebuggerStepThrough]
		public Task<OperateResult<Bitmap>> DownloadFileAsync(string fileName, string factory, string group, string id, Action<long, long> processReport)
		{
			IntegrationFileClient.<DownloadFileAsync>d__18 <DownloadFileAsync>d__ = new IntegrationFileClient.<DownloadFileAsync>d__18();
			<DownloadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<Bitmap>>.Create();
			<DownloadFileAsync>d__.<>4__this = this;
			<DownloadFileAsync>d__.fileName = fileName;
			<DownloadFileAsync>d__.factory = factory;
			<DownloadFileAsync>d__.group = group;
			<DownloadFileAsync>d__.id = id;
			<DownloadFileAsync>d__.processReport = processReport;
			<DownloadFileAsync>d__.<>1__state = -1;
			<DownloadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadFileAsync>d__18>(ref <DownloadFileAsync>d__);
			return <DownloadFileAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 上传本地的文件到服务器操作，如果该文件已经存在，那么就更新这个文件。<br />
		/// Upload a local file to the server. If the file already exists, update the file.
		/// </summary>
		/// <param name="fileName">本地的完整路径的文件名称</param>
		/// <param name="serverName">服务器存储的文件名称，带后缀，例如123.txt</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="fileTag">文件的额外描述</param>
		/// <param name="fileUpload">文件的上传人</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常，或是客户端不存在文件。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="Upload File" title="UploadFile示例" />
		/// </example>
		// Token: 0x060014D0 RID: 5328 RVA: 0x0006BC20 File Offset: 0x00069E20
		[HslMqttApi(Description = "Upload a local file to the server. If the file already exists, update the file.")]
		public OperateResult UploadFile(string fileName, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			bool flag = !File.Exists(fileName);
			OperateResult result;
			if (flag)
			{
				result = new OperateResult(StringResources.Language.FileNotExist);
			}
			else
			{
				result = base.UploadFileBase(fileName, serverName, factory, group, id, fileTag, fileUpload, processReport);
			}
			return result;
		}

		/// <summary>
		/// 上传本地的文件到服务器操作，服务器存储的文件名就是当前文件默认的名称
		/// </summary>
		/// <param name="fileName">本地的完整路径的文件名称</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="fileTag">文件的额外描述</param>
		/// <param name="fileUpload">文件的上传人</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014D1 RID: 5329 RVA: 0x0006BC64 File Offset: 0x00069E64
		public OperateResult UploadFile(string fileName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			bool flag = !File.Exists(fileName);
			OperateResult result;
			if (flag)
			{
				result = new OperateResult(StringResources.Language.FileNotExist);
			}
			else
			{
				FileInfo fileInfo = new FileInfo(fileName);
				result = base.UploadFileBase(fileName, fileInfo.Name, factory, group, id, fileTag, fileUpload, processReport);
			}
			return result;
		}

		/// <summary>
		/// 上传本地的文件到服务器操作，服务器存储的文件名就是当前文件默认的名称
		/// </summary>
		/// <param name="fileName">本地的完整路径的文件名称</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014D2 RID: 5330 RVA: 0x0006BCB4 File Offset: 0x00069EB4
		public OperateResult UploadFile(string fileName, string factory, string group, string id, Action<long, long> processReport)
		{
			bool flag = !File.Exists(fileName);
			OperateResult result;
			if (flag)
			{
				result = new OperateResult(StringResources.Language.FileNotExist);
			}
			else
			{
				FileInfo fileInfo = new FileInfo(fileName);
				result = base.UploadFileBase(fileName, fileInfo.Name, factory, group, id, "", "", processReport);
			}
			return result;
		}

		/// <summary>
		/// 上传本地的文件到服务器操作，服务器存储的文件名就是当前文件默认的名称，其余参数默认为空
		/// </summary>
		/// <param name="fileName">本地的完整路径的文件名称</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014D3 RID: 5331 RVA: 0x0006BD0C File Offset: 0x00069F0C
		public OperateResult UploadFile(string fileName, Action<long, long> processReport)
		{
			bool flag = !File.Exists(fileName);
			OperateResult result;
			if (flag)
			{
				result = new OperateResult(StringResources.Language.FileNotExist);
			}
			else
			{
				FileInfo fileInfo = new FileInfo(fileName);
				result = base.UploadFileBase(fileName, fileInfo.Name, "", "", "", "", "", processReport);
			}
			return result;
		}

		/// <summary>
		/// 上传数据流到服务器操作
		/// </summary>
		/// <param name="stream">数据流内容</param>
		/// <param name="serverName">服务器存储的文件名称，带后缀</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="fileTag">文件的额外描述</param>
		/// <param name="fileUpload">文件的上传人</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常，或是客户端不存在文件。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="Upload File" title="UploadFile示例" />
		/// </example>
		// Token: 0x060014D4 RID: 5332 RVA: 0x0006BD6C File Offset: 0x00069F6C
		public OperateResult UploadFile(Stream stream, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			return base.UploadFileBase(stream, serverName, factory, group, id, fileTag, fileUpload, processReport);
		}

		/// <summary>
		/// 上传内存图片到服务器操作
		/// </summary>
		/// <param name="bitmap">内存图片，不能为空</param>
		/// <param name="serverName">服务器存储的文件名称，带后缀</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <param name="fileTag">文件的额外描述</param>
		/// <param name="fileUpload">文件的上传人</param>
		/// <param name="processReport">上传的进度报告</param>
		/// <returns>是否成功的结果对象</returns>
		/// <exception cref="T:System.ArgumentNullException"></exception>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常，或是客户端不存在文件。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="Upload File" title="UploadFile示例" />
		/// </example>
		// Token: 0x060014D5 RID: 5333 RVA: 0x0006BD94 File Offset: 0x00069F94
		public OperateResult UploadFile(Bitmap bitmap, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			MemoryStream memoryStream = new MemoryStream();
			bool flag = bitmap.RawFormat != null;
			if (flag)
			{
				bitmap.Save(memoryStream, bitmap.RawFormat);
			}
			else
			{
				bitmap.Save(memoryStream, ImageFormat.Bmp);
			}
			OperateResult result = base.UploadFileBase(memoryStream, serverName, factory, group, id, fileTag, fileUpload, processReport);
			memoryStream.Dispose();
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014D6 RID: 5334 RVA: 0x0006BDF4 File Offset: 0x00069FF4
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(string fileName, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__25 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__25();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.fileName = fileName;
			<UploadFileAsync>d__.serverName = serverName;
			<UploadFileAsync>d__.factory = factory;
			<UploadFileAsync>d__.group = group;
			<UploadFileAsync>d__.id = id;
			<UploadFileAsync>d__.fileTag = fileTag;
			<UploadFileAsync>d__.fileUpload = fileUpload;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__25>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014D7 RID: 5335 RVA: 0x0006BE78 File Offset: 0x0006A078
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(string fileName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__26 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__26();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.fileName = fileName;
			<UploadFileAsync>d__.factory = factory;
			<UploadFileAsync>d__.group = group;
			<UploadFileAsync>d__.id = id;
			<UploadFileAsync>d__.fileTag = fileTag;
			<UploadFileAsync>d__.fileUpload = fileUpload;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__26>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014D8 RID: 5336 RVA: 0x0006BEF4 File Offset: 0x0006A0F4
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(string fileName, string factory, string group, string id, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__27 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__27();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.fileName = fileName;
			<UploadFileAsync>d__.factory = factory;
			<UploadFileAsync>d__.group = group;
			<UploadFileAsync>d__.id = id;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__27>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014D9 RID: 5337 RVA: 0x0006BF60 File Offset: 0x0006A160
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(string fileName, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__28 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__28();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.fileName = fileName;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__28>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.IO.Stream,System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014DA RID: 5338 RVA: 0x0006BFB4 File Offset: 0x0006A1B4
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(Stream stream, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__29 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__29();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.stream = stream;
			<UploadFileAsync>d__.serverName = serverName;
			<UploadFileAsync>d__.factory = factory;
			<UploadFileAsync>d__.group = group;
			<UploadFileAsync>d__.id = id;
			<UploadFileAsync>d__.fileTag = fileTag;
			<UploadFileAsync>d__.fileUpload = fileUpload;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__29>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.Drawing.Bitmap,System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})" />
		// Token: 0x060014DB RID: 5339 RVA: 0x0006C038 File Offset: 0x0006A238
		[DebuggerStepThrough]
		public Task<OperateResult> UploadFileAsync(Bitmap bitmap, string serverName, string factory, string group, string id, string fileTag, string fileUpload, Action<long, long> processReport)
		{
			IntegrationFileClient.<UploadFileAsync>d__30 <UploadFileAsync>d__ = new IntegrationFileClient.<UploadFileAsync>d__30();
			<UploadFileAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult>.Create();
			<UploadFileAsync>d__.<>4__this = this;
			<UploadFileAsync>d__.bitmap = bitmap;
			<UploadFileAsync>d__.serverName = serverName;
			<UploadFileAsync>d__.factory = factory;
			<UploadFileAsync>d__.group = group;
			<UploadFileAsync>d__.id = id;
			<UploadFileAsync>d__.fileTag = fileTag;
			<UploadFileAsync>d__.fileUpload = fileUpload;
			<UploadFileAsync>d__.processReport = processReport;
			<UploadFileAsync>d__.<>1__state = -1;
			<UploadFileAsync>d__.<>t__builder.Start<IntegrationFileClient.<UploadFileAsync>d__30>(ref <UploadFileAsync>d__);
			return <UploadFileAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 获取指定路径下的所有的文档<br />
		/// Get all documents in the specified path
		/// </summary>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <returns>是否成功的结果对象</returns>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="DownloadPathFileNames" title="DownloadPathFileNames示例" />
		/// </example>
		// Token: 0x060014DC RID: 5340 RVA: 0x0006C0BC File Offset: 0x0006A2BC
		[HslMqttApi(Description = "Get all documents in the specified path")]
		public OperateResult<GroupFileItem[]> DownloadPathFileNames(string factory, string group, string id)
		{
			return this.DownloadStringArrays<GroupFileItem>(2007, factory, group, id);
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadPathFileNames(System.String,System.String,System.String)" />
		// Token: 0x060014DD RID: 5341 RVA: 0x0006C0DC File Offset: 0x0006A2DC
		[DebuggerStepThrough]
		public Task<OperateResult<GroupFileItem[]>> DownloadPathFileNamesAsync(string factory, string group, string id)
		{
			IntegrationFileClient.<DownloadPathFileNamesAsync>d__32 <DownloadPathFileNamesAsync>d__ = new IntegrationFileClient.<DownloadPathFileNamesAsync>d__32();
			<DownloadPathFileNamesAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<GroupFileItem[]>>.Create();
			<DownloadPathFileNamesAsync>d__.<>4__this = this;
			<DownloadPathFileNamesAsync>d__.factory = factory;
			<DownloadPathFileNamesAsync>d__.group = group;
			<DownloadPathFileNamesAsync>d__.id = id;
			<DownloadPathFileNamesAsync>d__.<>1__state = -1;
			<DownloadPathFileNamesAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadPathFileNamesAsync>d__32>(ref <DownloadPathFileNamesAsync>d__);
			return <DownloadPathFileNamesAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 获取指定路径下的所有的目录<br />
		/// Get all directories under the specified path
		/// </summary>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <returns>是否成功的结果对象</returns>
		/// <remarks>
		/// 用于分类的参数<paramref name="factory" />，<paramref name="group" />，<paramref name="id" />中间不需要的可以为空，对应的是服务器上的路径系统。
		/// <br /><br />
		/// <note type="warning">
		/// 失败的原因大多数来自于网络的接收异常。
		/// </note>
		/// </remarks>
		/// <example>
		/// <code lang="cs" source="TestProject\HslCommunicationDemo\Hsl\FormFileClient.cs" region="DownloadPathFolders" title="DownloadPathFolders示例" />
		/// </example>
		// Token: 0x060014DE RID: 5342 RVA: 0x0006C138 File Offset: 0x0006A338
		[HslMqttApi(Description = "Get all directories under the specified path")]
		public OperateResult<string[]> DownloadPathFolders(string factory, string group, string id)
		{
			return this.DownloadStringArrays<string>(2008, factory, group, id);
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadPathFolders(System.String,System.String,System.String)" />
		// Token: 0x060014DF RID: 5343 RVA: 0x0006C158 File Offset: 0x0006A358
		[DebuggerStepThrough]
		public Task<OperateResult<string[]>> DownloadPathFoldersAsync(string factory, string group, string id)
		{
			IntegrationFileClient.<DownloadPathFoldersAsync>d__34 <DownloadPathFoldersAsync>d__ = new IntegrationFileClient.<DownloadPathFoldersAsync>d__34();
			<DownloadPathFoldersAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<string[]>>.Create();
			<DownloadPathFoldersAsync>d__.<>4__this = this;
			<DownloadPathFoldersAsync>d__.factory = factory;
			<DownloadPathFoldersAsync>d__.group = group;
			<DownloadPathFoldersAsync>d__.id = id;
			<DownloadPathFoldersAsync>d__.<>1__state = -1;
			<DownloadPathFoldersAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadPathFoldersAsync>d__34>(ref <DownloadPathFoldersAsync>d__);
			return <DownloadPathFoldersAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 检查当前的文件是否在服务器端存在，列表中需要存在文件的名称，映射的文件也需要存在。<br />
		/// Check whether the current file exists on the server side, the name of the file must exist in the list, and the mapped file must also exist.
		/// </summary>
		/// <param name="fileName">当前的文件名称，举例123.txt</param>
		/// <param name="factory">第一级分类信息</param>
		/// <param name="group">第二级分类信息</param>
		/// <param name="id">第三级分类信息</param>
		/// <returns>是否存在，存在返回true, 否则，返回false</returns>
		// Token: 0x060014E0 RID: 5344 RVA: 0x0006C1B4 File Offset: 0x0006A3B4
		public OperateResult<bool> IsFileExists(string fileName, string factory, string group, string id)
		{
			OperateResult<Socket> operateResult = base.CreateSocketAndConnect(base.ServerIpEndPoint, base.ConnectTimeOut);
			bool flag = !operateResult.IsSuccess;
			OperateResult<bool> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<bool>(operateResult);
			}
			else
			{
				OperateResult operateResult2 = base.SendStringAndCheckReceive(operateResult.Content, 2013, fileName);
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<bool>(operateResult2);
				}
				else
				{
					OperateResult operateResult3 = base.SendFactoryGroupId(operateResult.Content, factory, group, id);
					bool flag3 = !operateResult3.IsSuccess;
					if (flag3)
					{
						result = OperateResult.CreateFailedResult<bool>(operateResult3);
					}
					else
					{
						OperateResult<int, string> operateResult4 = base.ReceiveStringContentFromSocket(operateResult.Content, 30000);
						bool flag4 = !operateResult4.IsSuccess;
						if (flag4)
						{
							result = OperateResult.CreateFailedResult<bool>(operateResult4);
						}
						else
						{
							OperateResult<bool> operateResult5 = OperateResult.CreateSuccessResult<bool>(operateResult4.Content1 == 1);
							Socket content = operateResult.Content;
							if (content != null)
							{
								content.Close();
							}
							result = operateResult5;
						}
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.IsFileExists(System.String,System.String,System.String,System.String)" />
		// Token: 0x060014E1 RID: 5345 RVA: 0x0006C29C File Offset: 0x0006A49C
		[DebuggerStepThrough]
		public Task<OperateResult<bool>> IsFileExistsAsync(string fileName, string factory, string group, string id)
		{
			IntegrationFileClient.<IsFileExistsAsync>d__36 <IsFileExistsAsync>d__ = new IntegrationFileClient.<IsFileExistsAsync>d__36();
			<IsFileExistsAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<bool>>.Create();
			<IsFileExistsAsync>d__.<>4__this = this;
			<IsFileExistsAsync>d__.fileName = fileName;
			<IsFileExistsAsync>d__.factory = factory;
			<IsFileExistsAsync>d__.group = group;
			<IsFileExistsAsync>d__.id = id;
			<IsFileExistsAsync>d__.<>1__state = -1;
			<IsFileExistsAsync>d__.<>t__builder.Start<IntegrationFileClient.<IsFileExistsAsync>d__36>(ref <IsFileExistsAsync>d__);
			return <IsFileExistsAsync>d__.<>t__builder.Task;
		}

		/// <summary>
		/// 获取指定路径下的所有的路径或是文档信息
		/// </summary>
		/// <param name="protocol">指令</param>
		/// <param name="factory">第一大类</param>
		/// <param name="group">第二大类</param>
		/// <param name="id">第三大类</param>
		/// <typeparam name="T">数组的类型</typeparam>
		/// <returns>是否成功的结果对象</returns>
		// Token: 0x060014E2 RID: 5346 RVA: 0x0006C300 File Offset: 0x0006A500
		private OperateResult<T[]> DownloadStringArrays<T>(int protocol, string factory, string group, string id)
		{
			OperateResult<Socket> operateResult = base.CreateSocketAndConnect(base.ServerIpEndPoint, base.ConnectTimeOut);
			bool flag = !operateResult.IsSuccess;
			OperateResult<T[]> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<T[]>(operateResult);
			}
			else
			{
				OperateResult operateResult2 = base.SendStringAndCheckReceive(operateResult.Content, protocol, "nosense");
				bool flag2 = !operateResult2.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<T[]>(operateResult2);
				}
				else
				{
					OperateResult operateResult3 = base.SendFactoryGroupId(operateResult.Content, factory, group, id);
					bool flag3 = !operateResult3.IsSuccess;
					if (flag3)
					{
						result = OperateResult.CreateFailedResult<T[]>(operateResult3);
					}
					else
					{
						OperateResult<int, string> operateResult4 = base.ReceiveStringContentFromSocket(operateResult.Content, 30000);
						bool flag4 = !operateResult4.IsSuccess;
						if (flag4)
						{
							result = OperateResult.CreateFailedResult<T[]>(operateResult4);
						}
						else
						{
							Socket content = operateResult.Content;
							if (content != null)
							{
								content.Close();
							}
							try
							{
								result = OperateResult.CreateSuccessResult<T[]>(JArray.Parse(operateResult4.Content2).ToObject<T[]>());
							}
							catch (Exception ex)
							{
								result = new OperateResult<T[]>(ex.Message);
							}
						}
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadStringArrays``1(System.Int32,System.String,System.String,System.String)" />
		// Token: 0x060014E3 RID: 5347 RVA: 0x0006C414 File Offset: 0x0006A614
		[DebuggerStepThrough]
		private Task<OperateResult<T[]>> DownloadStringArraysAsync<T>(int protocol, string factory, string group, string id)
		{
			IntegrationFileClient.<DownloadStringArraysAsync>d__38<T> <DownloadStringArraysAsync>d__ = new IntegrationFileClient.<DownloadStringArraysAsync>d__38<T>();
			<DownloadStringArraysAsync>d__.<>t__builder = AsyncTaskMethodBuilder<OperateResult<T[]>>.Create();
			<DownloadStringArraysAsync>d__.<>4__this = this;
			<DownloadStringArraysAsync>d__.protocol = protocol;
			<DownloadStringArraysAsync>d__.factory = factory;
			<DownloadStringArraysAsync>d__.group = group;
			<DownloadStringArraysAsync>d__.id = id;
			<DownloadStringArraysAsync>d__.<>1__state = -1;
			<DownloadStringArraysAsync>d__.<>t__builder.Start<IntegrationFileClient.<DownloadStringArraysAsync>d__38<T>>(ref <DownloadStringArraysAsync>d__);
			return <DownloadStringArraysAsync>d__.<>t__builder.Task;
		}

		/// <inheritdoc />
		// Token: 0x060014E4 RID: 5348 RVA: 0x0006C475 File Offset: 0x0006A675
		public override string ToString()
		{
			return string.Format("IntegrationFileClient[{0}]", base.ServerIpEndPoint);
		}
	}
}
